/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package me.panpf.sketch.util;

import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

/**
 * Log
 */
public class Log {
    /**
     * HiLogLabel
     */
    public static final HiLogLabel hiLogLabel = new HiLogLabel(HiLog.INFO, 0x001, "HMOS");

    /**
     * info
     * @param tag
     * @param info
     * @return String
     */
    public static String info(String tag, String info) {
        HiLog.info(hiLogLabel, tag, info);
        Logger.getLogger(tag).info(info);
        return info;
    }

    /**
     * debug
     * @param tag
     * @param info
     * @return String
     */
    public static String debug(String tag, String info) {
        HiLog.info(hiLogLabel, tag, info);
        Logger.getLogger(tag).info(info);
        return info;
    }

    /**
     * info
     * @param info
     * @return String
     */
    public static String info(String info) {
        HiLog.info(hiLogLabel, "zhanghao", info);
        Logger.getLogger("zhanghao").info(info);
        return info;
    }

    /**
     * warn
     * @param info
     * @return String
     */
    public static String warn(String info) {
        HiLogLabel hiLogLabelTemp = new HiLogLabel(HiLog.WARN, 0x001, "HMOS");
        HiLog.info(hiLogLabelTemp, "eg", info);
        Logger.getLogger("eg").info(info);
        return info;
    }

    /**
     * warn
     * @param tag
     * @param info
     * @return String
     */
    public static String warn(String tag, String info) {
        HiLogLabel hiLogLabelTemp = new HiLogLabel(HiLog.WARN, 0x001, "HMOS");
        HiLog.error(hiLogLabelTemp, tag, info);
        Logger.getLogger(tag).warning(info);
        return info;
    }

    /**
     * error
     * @param tag
     * @param info
     * @return String
     */
    public static String error(String tag, String info) {
        HiLog.error(hiLogLabel, tag, info);
        Logger.getLogger(tag).warning(info);
        return info;
    }

    /**
     * error
     * @param info
     * @param t1
     * @return String
     */
    public static String error(String info, Throwable t1) {
        HiLog.error(hiLogLabel, "错误", info + "错误:" + t1.getMessage());
        return info;
    }

}
